﻿using AccessControl.Sida.DataAccess;

namespace AccessControl.Sida.Business
{
    public class StudentAccessBuisness
    {
        public static bool IsStudentAllowed(string studentCode, int pkEventType, int pkEvent, out string reason)
        {
            reason = "";
            if (pkEventType == 1)
            {
                var row = StudentBasicInfoAccess.GetStudentStatus(studentCode);
                if (row == null)
                {

                    reason = "دانشجو در بانک کاده وجود ندارد";
                    return false;
                }
                if (row.idvazkol != 1 && row.idvazkol != 2)
                {
                    reason = "وضعیت دانشجو عادی نیست";
                    return false;
                }
                return true;
            }
            if (pkEventType == 2){
                return DormitoryAccess.IsStudentRegistered(studentCode, out reason);
            }
            return true;
        }
    }

}


